package com.flyduck.vueshop.auth.admin.controller;

import com.flyduck.vueshop.auth.admin.service.AdminLoginService;
import com.flyduck.vueshop.auth.admin.vo.AdminLoginReqVO;
import com.flyduck.vueshop.auth.admin.vo.AdminLoginRespVO;
import com.flyduck.vueshop.auth.admin.vo.AdminUserInfoRespVO;
import com.flyduck.vueshop.common.core.lang.Result;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * SysLoginController
 * </p>
 *
 * @author flyduck
 * @since 2024-07-09
 */
@RestController
@RequestMapping("/auth/sys")
public class AdminLoginController {

    @Resource
    private AdminLoginService adminLoginService;

    @PostMapping("/login")
    public Result<AdminLoginRespVO> login(@Validated @RequestBody AdminLoginReqVO adminLoginReqVO){
        AdminLoginRespVO adminLoginRespVO = adminLoginService.login(adminLoginReqVO);
        return Result.success(adminLoginRespVO);
    }


    @GetMapping("/getUserInfo")
    public Result<AdminUserInfoRespVO> getUserInfo(){
        AdminUserInfoRespVO adminUserInfoRespVO = adminLoginService.getUserInfo();
        return Result.success(adminUserInfoRespVO);
    }
}
